*********The two faces of power-sharing - Replication 2: IV approaches*********

*insheet using "WORKING DIRECTORY\two_faces_power_sharing_replication_data.csv"
insheet using"/Users/andreasjuon/Documents/PhD/Papers/17_06_Paper_Power_Sharing/Paper/version_20_11/two_faces_replication/two_faces_power_sharing_replication_data.csv"
gen loggdppc_l1 = log(gdppc_l1)
gen logpop_l1 = log(pop_l1)
gen logoilrents_l1 = log(oilrents_l1 + 0.00001)
gen logd10_bdead_allc_pc_l1 = log(d10_bdead_allc_pc_l1 + 1)
gen year2 = year
xtset gwid year



********IV models with country-clustered SE's and Fixed Effects********

*****IV Models with external actors (regions, interveners, mediators)****

****Model 4.1: NeldaiC, PS_corp / PS_lib
xtivreg2 neldaic (ps1h_corp_l1 ps1h_lib_l1 = d20_ps1h_corp_intervener_l1 d20_ps1h_corp_mediator_l1 ps1h_corp_meanr_l1 d20_ps1h_lib_intervener_l1 d20_ps1h_lib_mediator_l1 ps1h_lib_meanr_l1) loggdppc_l1 logpop_l1 logoilrents_l1 fractionalization1_l1 nopluralitysum_l1 postconflict_l1 d10_victory_neg_l1 logd10_bdead_allc_pc_l1 d10_un_intervention_plus_l1 year2 neldaic_meanr_l1 d20_mediation_l1 d20_milit_int_l1, cluster(gwid) fe first ffirst savefprefix(first4_1)
estimates store m4_1
****Figure A.4a: AR confidence sets
weakiv, graph(ar) arlevel (90)
****Model 4.2: PolityC, PS_corp / PS_lib
xtivreg2 polityc (ps1h_corp_l1 ps1h_lib_l1 = d20_ps1h_corp_intervener_l1 d20_ps1h_corp_mediator_l1 ps1h_corp_meanr_l1 d20_ps1h_lib_intervener_l1 d20_ps1h_lib_mediator_l1 ps1h_lib_meanr_l1) loggdppc_l1 logpop_l1 logoilrents_l1 fractionalization1_l1 nopluralitysum_l1 postconflict_l1 d10_victory_neg_l1 logd10_bdead_allc_pc_l1 d10_un_intervention_plus_l1 year2 polityc_meanr_l1 d20_mediation_l1 d20_milit_int_l1, cluster(gwid) fe first ffirst savefprefix(first4_2)
estimates store m4_2
****Figure A.4b: AR confidence sets
weakiv, graph(ar) arlevel (90)


*****IV Models Relying on Colonial heritage*****

gen logdistance_coast_avg_l1 = log(distance_coast_avg_l1+0.000001)
gen former_brit_logd_coast_avg_l1 = former_brit * logdistance_coast_avg_l1
xtset, clear

****Model 5.1: NeldaiC
ivreg2 neldaic (ps1h_corp_l1 = former_brit_logd_coast_avg_l1) ps1h_lib_l1 loggdppc_l1 logpop_l1 logoilrents_l1 fractionalization1_l1 nopluralitysum_l1 postconflict_l1 d10_victory_neg_l1 logd10_bdead_allc_pc_l1 d10_un_intervention_plus_l1 year2 neldaic_meanr_l1 former_brit logdistance_coast_avg_l1 if (former_fran==1 | former_brit==1) & ((gwid >= 400 & gwid < 600) | (gwid >= 700 & gwid < 900)), cluster(gwid) first ffirst savefprefix(first5_1)
estimates store m5_1
****Figure A.5a: AR confidence sets
weakiv, graph(ar) arlevel (90)

****Model 5.2: PolityC
ivreg2 polityc (ps1h_corp_l1 = former_brit_logd_coast_avg_l1) ps1h_lib_l1 loggdppc_l1 logpop_l1 logoilrents_l1 fractionalization1_l1 nopluralitysum_l1 postconflict_l1 d10_victory_neg_l1 logd10_bdead_allc_pc_l1 d10_un_intervention_plus_l1 year2 polityc_meanr_l1 former_brit logdistance_coast_avg_l1 if (former_fran==1 | former_brit==1) & ((gwid >= 400 & gwid < 600) | (gwid >= 700 & gwid < 900)), cluster(gwid) first ffirst savefprefix(first5_2)
estimates store m5_2
****Figure A.5b: AR confidence sets
weakiv, graph(ar) arlevel (90)


****export second stage all models (Table IV)
outreg2 [m4_1 m4_2 m5_1 m5_2] using "WORKING DIRECTORY\table_iv.csv",  alpha(0.01, 0.05, 0.1) symbol(**,*,†) replace


****export first stage approach (Table III)
est restore first4_1ps1h_corp_l1
outreg2  using "WORKING DIRECTORY\figures\main\table_iii.csv",  alpha(0.01, 0.05, 0.1) symbol(**,*,†) replace
est restore first4_2ps1h_corp_l1
outreg2  using "WORKING DIRECTORY\figures\main\table_iii.csv",  alpha(0.01, 0.05, 0.1) symbol(**,*,†)
est restore first4_1ps1h_lib_l1
outreg2  using "WORKING DIRECTORY\figures\main\table_iii.csv",  alpha(0.01, 0.05, 0.1) symbol(**,*,†)
est restore first4_2ps1h_lib_l1
outreg2  using "WORKING DIRECTORY\figures\main\table_iii.csv",  alpha(0.01, 0.05, 0.1) symbol(**,*,†)
est restore first5_1ps1h_corp_l1
outreg2  using "WORKING DIRECTORY\figures\main\table_iii.csv",  alpha(0.01, 0.05, 0.1) symbol(**,*,†)
est restore first5_2ps1h_corp_l1
outreg2  using "WORKING DIRECTORY\figures\main\table_iii.csv",  alpha(0.01, 0.05, 0.1) symbol(**,*,†)
